﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dos.ORM;
using Dln.Common;
using Dln.Common.Helper;
using Dln.Model;

public partial class Page_日常工作_WorkSoultionEdit : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int IDPlus = Convert.ToInt32(Request.QueryString["IDPlus"]);
            if (IDPlus > 0)
            {
                SetArticleInfo(IDPlus);
            }
        }
    }

    /// <summary>
    /// 设置问题信息
    /// </summary>
    /// <param name="_IDPlus"></param>
    private void SetArticleInfo(int _IDPlus)
    {

        var problemTypesList = SqlHelper.Context.From<ProblemTypes>().ToList();
        if (problemTypesList != null && problemTypesList.Count > 0)
        {
            //查询时
            selectArticleType.DataSource = problemTypesList;
            selectArticleType.DataTextField = "TypeName";
            selectArticleType.DataValueField = "Id";
            selectArticleType.DataBind();
        }

        var list = SqlHelper.Context.From<WorkSoultion>()
                .Where(d => d.Id == _IDPlus)
                .ToList();
        if (list != null && list.Count > 0)
        {
            var model = list.FirstOrDefault();

            this.txtArticleTitle.Value = model.Title;
            this.txtArticleContent.Value = model.Describe;
            this.selectArticleType.SelectedIndex = selectArticleType.Items.IndexOf(selectArticleType.Items.FindByValue(model.Type.ToString()));
            this.txtArticleContent1.Value = model.Solution;

        }
    }
}